import { createElement, useEffect, useState } from "react";
import { Cascader } from "antd";
import "antd/dist/antd.css";
import { AreaLinkageContainerProps } from "../../typings/AreaLinkageProps";

export function CascaderUI(option:string, props:AreaLinkageContainerProps) {
    const [value, setvalue] = useState<string>();
    useEffect(() => {
        if (props.responseAttribute) {
            setvalue(String(props.responseAttribute.value));
        }
    }, [props.responseAttribute]);
    return(
            <Cascader
                options = {JSON.parse(option)}
                defaultValue={JSON.parse(value || "{}")}
            />
        )
}
// default值通过绑定的变量渲染，否则使用行政区域的整个数据options进行渲染